// packageC/pages/Collarcoupons/Collarcoupons.js
var common = require("../../../public.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
        platformId: ""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    //跳转领券详情
    go_CoupList(e) {
        console.log(e, "dayin")
        let {
            item
        } = e.currentTarget.dataset
        console.log(item, "ghggg")
        //  预约券
        if (item.couponType == 6) {
            wx.navigateTo({
                url: `/packageC/pages/coups/signUp?activId=${item.activId}&imgUrl=${item.imgUrl}&isOnline=${item.isOnline}`,
            })
            return
        }
        wx.navigateTo({
            url: '/packageC/pages/coupCenterGet/coupCenterGet?isOffLine=' + item.isOnline +
                '&managerId=' + item.activId + '&activStatus=' + item.activStatus,
        })
    },
    onLoad: function (options) {
        console.log(options, "55145")
        this.setData({
            platformId: options.platformId ? options.platformId : 2
        }, () => {
            this.geCoupList()
        })
    },
    geCoupList() { // 获取余额
        const that = this
        const tempJson = {
            platformId: that.data.platformId
        }
        common.post('/couponCenter/getActivsForPlatform', tempJson, function (res) {
            if (res.status === 200) {
               
                for (var i = 0; i < res.data.data.length; i++) {
                    res.data.data[i].beginTime = parseInt(res.data.data[i].beginTime) * 1000
                    res.data.data[i].finishTime = parseInt(res.data.data[i].finishTime) * 1000
                    res.data.data[i].beginTime = common.dateFormat('yyyy-MM-dd HH:mm', res.data.data[i].beginTime)
                    res.data.data[i].finishTime = common.dateFormat('yyyy-MM-dd HH:mm', res.data.data[i].finishTime)
                }
                that.setData({
                    coupList: res.data.data
                })
            } else {
                common.showRequestErrMsg(res)
            }
        })
    },
})